﻿Imports System.Data
Imports System.Data.OracleClient
Imports System.Windows.Forms
Imports WindowsApplication1.funciones

Public Class Abono

    'conexion para inicializar la barra del navegador
    Dim conexion As String = "Driver={Microsoft ODBC for Oracle};Server=xe;Uid=redes;Pwd=redes;"

    'query para el dgv
    Dim querydgv As String = " select * from TB_VNT_ABONO"

    'variables a incluir si van a llenar un combo
    Dim querycomboic As String = "select ID_CUENTA from TB_VNT_CUENTAS_COBRAR"

    Dim valuecomboic As String = "ID_CUENTA"
    Dim displaycomic As String = "ID_CUENTA"

    Dim querysecuencia As String = "select max(ID_ABONO)+ 1 as ID_ABONO from TB_VNT_ABONO"
    Dim camposecuencia As String = "ID_ABONO"
    Dim temp As String = traersecuencia(querysecuencia, camposecuencia)

    'variables para llenado del vector
    Dim sizevector As Integer = 4
    Dim vector(sizevector) As TextBox

    'variable para llevar la secuencia en el campo ID
    Public Function LlenarVector() As TextBox()
        vector(0) = TextIAbo
        vector(1) = TextFeAbo
        vector(2) = TextMon
        vector(3) = txt_nota
        vector(4) = TextICue

        Return vector
    End Function

    Private Sub Abono_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        vector = LlenarVector()
        BarraNavegacion1.Inicializar(conexion, "TB_VNT_ABONO", vector)
        'para llevar la secuencia del codigo
        'para mostrar la fecha en el texbox en formato corto
        TextFeAbo.Text = Date.Today.ToShortDateString
        'llenado del combo
        llenarcombo(ComboICuenta, querycomboic, valuecomboic, displaycomic)
        'llenado del datagridview
        DGVAbono.DataSource = LlenarDgv(querydgv)
        'llenado del vector
        TextIAbo.Text = temp

    End Sub
    Private Sub ComboICuenta_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboICuenta.TextChanged
        If ComboICuenta.ValueMember.Any Then
            TextICue.Text = ComboICuenta.SelectedValue
        End If

    End Sub


    Private Sub TextIAbo_EnabledChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextIAbo.EnabledChanged
        'MessageBox.Show("Se ha cambiado la propiedad enabled del texto1 a:" + TEXTO1.Enabled.ToString)
        TextIAbo.Enabled = False
        

    End Sub
    Private Sub TextFeAbo_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextFeAbo.TextChanged
        If TextFeAbo.Text = "" Then
            TextFeAbo.Text = Date.Today.ToShortDateString
        End If
    End Sub

  
    Private Sub btn_actualiza_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_actualiza.Click
        DGVAbono.DataSource = LlenarDgv(querydgv)
    End Sub

   
    Private Sub TextMon_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextMon.TextChanged
   
    End Sub

    Private Sub TextIAbo_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextIAbo.TextChanged
        Dim querysecuencia2 As String = "select max(ID_ABONO)+ 1 as ID_ABONO from TB_VNT_ABONO"
        Dim camposecuencia2 As String = "ID_ABONO"
        Dim temp2 As String = traersecuencia(querysecuencia2, camposecuencia2)
        If TextIAbo.Text = "" Then
            TextIAbo.Text = temp2
            ComboICuenta.Text = ""
        End If
    End Sub
End Class